//
//  CustomPaopaoView.m
//  i5db
//
//  Created by iMuse on 15-5-28.
//  Copyright (c) 2015年 mySelf. All rights reserved.
//

#import "CustomPaopaoView.h"
#import "AppCenter.h"
@implementation CustomPaopaoView

- (id)init :(NSString*) title
{
    self = [super init];
    if (self) {
        self.title = title;
        [self initView];
        
    }
    return self;
}
-(void) initView
{
    
    
    UILabel * label = [[UILabel alloc] init];
    label.font = [UIFont systemFontOfSize:12];
    
    label.textColor = [UIColor whiteColor];
    
    label.text = self.title;
    
    CGSize size =   [AppCenter sizeWithString:self.title font:label.font maxHeight:46 maxWeight:320];
    
    self.frame = CGRectMake(0, 0, 85+size.width+20, 46);
    
    UIImageView * tranImageView = [[UIImageView alloc] init];
    tranImageView.image = [UIImage imageNamed:@"wl_map_icon_4"];
    tranImageView.frame = CGRectMake(0, 0, 16, 10);
    tranImageView.center = CGPointMake(self.center.x, self.frame.size.height+5);
    [self addSubview:tranImageView];
    
    UIView * leftView = [[UIView alloc] init];
    leftView.frame = CGRectMake(0, 0, self.frame.size.width-65, 46);
    [self addSubview:leftView];
    
    UIImageView * imageView = [[UIImageView alloc] init];
    imageView.frame = self.frame;
    imageView.image = [[UIImage imageNamed:@"wl_map_icon_5.png"] stretchableImageWithLeftCapWidth:28 topCapHeight:16];
    [leftView addSubview:imageView];
    
    label.frame = CGRectMake(20, 0, leftView.frame.size.width-20, leftView.frame.size.height);
    [leftView addSubview:label];
    
    
    UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button addTarget:self action:@selector(selectMaptype:) forControlEvents:UIControlEventTouchUpInside];
    button.frame = CGRectMake(leftView.frame.size.width, 0, 65, 46);
    [button setBackgroundImage:[UIImage imageNamed:@"wl_map_icon_1"] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:@"wl_map_icon_1_press"] forState:UIControlStateSelected];
    [self addSubview:button];
    

    
}
-(void)selectMaptype:(UIButton*) button
{

    if ([self.delegate respondsToSelector:@selector(selectMap)])
    {
        [self.delegate performSelector:@selector(selectMap)];
    }
}



@end
